﻿/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2012-2018. All rights reserved.
 * Description:
 * Author: 辛爱国 x30005137
 * Create: 2020-07-28
 * Notes: 无
 */
#include "collectlogdialog.h"
#include <QPixmap>
#include <QGraphicsDropShadowEffect>
#include <qapplication.h>
#include <QDesktopWidget>
#include <qscreen.h>
CollectLogDialog::CollectLogDialog(QWidget *parent) : HWDialog(parent)
{
    setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
    this->m_wait = new QTimer(this);
    this->m_wait->setInterval(200);            // 定时器设置200
    connect(this->m_wait, SIGNAL(timeout()), this, SLOT(updateWait()));
    this->m_wait->start();
    QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect(this);
    shadow_effect->setOffset(0, 0);
    shadow_effect->setColor(Qt::gray);
    shadow_effect->setBlurRadius(10);          // 阴影设置半径10
    this->widgetWindow->setGraphicsEffect(shadow_effect);
    saveChildrenInfo();
}
void CollectLogDialog::updateWait()
{
    QMatrix matrix;
    QPixmap image_wait(":/image/images/31.png");
    image_wait.scaled(this->labelCollectLogo->size(), Qt::KeepAspectRatio);
    matrix.rotate(90 * this->m_spinIndex); // 每次旋转90°
    this->labelCollectLogo->setScaledContents(true);
    this->labelCollectLogo->setPixmap(image_wait.transformed(matrix, Qt::FastTransformation));
    this->m_spinIndex > 2 ? this->m_spinIndex = 0 : this->m_spinIndex++; // 0 1 2 3 四次一个轮回
}

CollectLogDialog::~CollectLogDialog()
{
    if (m_wait) {
        delete m_wait;
        m_wait = nullptr;
    }
}
void CollectLogDialog::on_pushButtonExit_clicked()
{
    hide();
}
void CollectLogDialog::on_pushButtonOK_clicked()
{
    hide();
}